#include "MediaFormatFactoryWindow.h"
#include "MediaFormatFactoryThread.h"
#include <QFileDialog>
#include <qmessagebox.h>

MediaFormatFactoryWindow::MediaFormatFactoryWindow(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	this->setWindowTitle("媒体给转换mp4->mov");
}

void MediaFormatFactoryWindow::inputFilePath()
{
	QString filter = "RGB 文件 (*.*);;所有文件 (*.*)";
	QString filePath = QFileDialog::getOpenFileName(this, "选择要转换的文件", "E:\\BaiduNetdiskDownload\\test_resource", filter);
	this->inputFile = filePath;
	ui.inFilePathEdit->setText(this->inputFile);
}
void MediaFormatFactoryWindow::outFilePath()
{
	QString directoryPath = QFileDialog::getSaveFileName(nullptr, "选择输出文件路径", "E:\\BaiduNetdiskDownload\\test_resource", "媒体文件(*.*)");
	this->outputFile = directoryPath;
	ui.outFilePathEdit->setText(this->outputFile);
}
void MediaFormatFactoryWindow::startFormatChange()
{
	QString inPath = ui.inFilePathEdit->text();
	QString outPath = ui.outFilePathEdit->text();
	if (inPath.isEmpty() || outPath.isEmpty()) {
		QMessageBox::warning(this, "温馨提示", "输入、输出文件的路径不能为空");
		return;
	}
	MediaFormatFactoryThread::Get()->inFile = inPath;
	MediaFormatFactoryThread::Get()->outFile = outPath;
	MediaFormatFactoryThread::Get()->Start();
}

MediaFormatFactoryWindow::~MediaFormatFactoryWindow()
{
}
